package com.tl.sun.manager;

import com.tl.sun.utils.core.MDAppUtils;

import java.io.Serializable;

/**
 * 作者：HQY on 17/8/21 16:50
 * 邮箱：hqy_xz@126.com
 */

public class MDModel implements Serializable, Cloneable {
    public static final String TAG = "model_object";


    private static MDModel instance;


    private int ipAreaOne;
    private int ipExpireOne;
    private int ipUsedOne;
    private int ipAreaTwo;
    private int ipExpireTwo;
    private int ipUsedTwo;
    private int ipAreaThree;
    private int ipExpireThree;
    private int ipUsedThree;
    private String cityList;
    private String shieldCity;
    private String isSenior;
    private String isOpen;

    private int model;

    public static MDModel getInstance() {
        if (instance == null) {
            synchronized (MDModel.class) {
                Object object = MDAppUtils.restoreObject(TAG);
                if (object == null) {
                    object = new MDModel();
                    MDAppUtils.saveObject(TAG, object);
                }

                instance = (MDModel) object;
            }
        }
        return instance;
    }


    public void writeToCache() {
        MDAppUtils.saveObject(TAG, this);
    }

    public void reset() {
        clearData();
        MDAppUtils.saveObject(TAG, this);
    }

    public void clearCache() {
        clearData();
        MDAppUtils.saveObject(TAG, this);
    }

    private void clearData() {
        ipAreaOne = 0;
        ipExpireOne = 0;
        ipUsedOne = 0;
        ipAreaTwo = 0;
        ipExpireTwo = 0;
        ipUsedTwo = 0;
        ipAreaThree = 0;
        ipExpireThree = 0;
        ipUsedThree = 0;
        cityList = null;
        shieldCity = null;
        model = 0;
        isSenior = "";
        isOpen = "";

    }

    public int getModel() {
        return model;
    }

    public void setModel(int model) {
        this.model = model;
    }

    public int getIpAreaOne() {
        return ipAreaOne;
    }

    public void setIpAreaOne(int ipAreaOne) {
        this.ipAreaOne = ipAreaOne;
    }

    public int getIpExpireOne() {
        return ipExpireOne;
    }

    public void setIpExpireOne(int ipExpireOne) {
        this.ipExpireOne = ipExpireOne;
    }

    public int getIpUsedOne() {
        return ipUsedOne;
    }

    public void setIpUsedOne(int ipUsedOne) {
        this.ipUsedOne = ipUsedOne;
    }

    public int getIpAreaTwo() {
        return ipAreaTwo;
    }

    public void setIpAreaTwo(int ipAreaTwo) {
        this.ipAreaTwo = ipAreaTwo;
    }

    public int getIpExpireTwo() {
        return ipExpireTwo;
    }

    public void setIpExpireTwo(int ipExpireTwo) {
        this.ipExpireTwo = ipExpireTwo;
    }

    public int getIpUsedTwo() {
        return ipUsedTwo;
    }

    public void setIpUsedTwo(int ipUsedTwo) {
        this.ipUsedTwo = ipUsedTwo;
    }

    public int getIpAreaThree() {
        return ipAreaThree;
    }

    public void setIpAreaThree(int ipAreaThree) {
        this.ipAreaThree = ipAreaThree;
    }

    public int getIpExpireThree() {
        return ipExpireThree;
    }

    public void setIpExpireThree(int ipExpireThree) {
        this.ipExpireThree = ipExpireThree;
    }

    public int getIpUsedThree() {
        return ipUsedThree;
    }

    public void setIpUsedThree(int ipUsedThree) {
        this.ipUsedThree = ipUsedThree;
    }

    public String getCityList() {
        return cityList;
    }

    public void setCityList(String cityList) {
        this.cityList = cityList;
    }

    public String getShieldCity() {
        return shieldCity;
    }

    public void setShieldCity(String shieldCity) {
        this.shieldCity = shieldCity;
    }

    public String getIsSenior() {
        return isSenior == null ? "" : isSenior;
    }

    public void setIsSenior(String isSenior) {
        this.isSenior = isSenior;
    }

    public String getIsOpen() {
        return isOpen == null ? "" : isOpen;
    }

    public void setIsOpen(String isOpen) {
        this.isOpen = isOpen;
    }
}
